<!doctype html>
<html class="x-admin-sm">
<#include "../header.ftl">
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" id="id" value="${(user.id)!}" name="id">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>输入密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>请记住密码
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;
        //自定义验证规则
        form.verify({
            // nikename: function(value) {
            //     if (value.length < 5) {
            //         return '昵称至少得5个字符啊';
            //     }
            // }
        });
        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data);
            layer.confirm("确定要重置密码吗？",{btn: ['确定', '取消'], title: "提示"},function(){
                $.ajax({
                    type: "POST",                      //请求类型
                    url: "./userEdit?v=submitResetPwd",                 //URL
                    data: data.field,                  //传递的参数
                    dataType: "json",                 //返回的数据类型
                    success: function (data) {          //data就是返回的json类型的数据
                        console.log(JSON.stringify(data));
                        if (data.code == 1) {
                            layer.alert("操作成功", {icon: 6}, function () {
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(data.msg)
                        }
                    },
                    error: function (data) {
                    }
                });
            });
            return false;
        });
    });
</script>
</body>
</html>